Add optional parameter to configuration providers for non-blocking startup#1745
Add optional parameter to configuration providers for non-blocking startup#1745GeorgeTsiokos wants to merge 3 commits intodapr:masterfrom
Conversation
|
Do note that I just merged a PR to support xUnit v3 so your unit/integration tests may need a refresh. |
…artup Configuration and secret store providers now accept an `optional` parameter that allows applications to start without blocking on sidecar availability. When optional, configuration loads in the background with resilient retry logic that handles transient Dapr errors gracefully. - Add `optional` parameter to AddDaprConfigurationStore and AddDaprSecretStore - Harden LoadInBackgroundAsync to catch OperationCanceledException and DaprException separately, avoiding silent swallowing of programming errors - Dispose CancellationTokenSource in both providers to prevent resource leaks - Fix StringComparer inconsistency (InvariantCultureIgnoreCase → OrdinalIgnoreCase) - Mark fields readonly in DaprConfigurationStoreProvider for consistency - Restore UTF-8 BOM per .editorconfig and add missing trailing newlines - Add deterministic tests using reload tokens instead of fragile Task.Delay Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: George Tsiokos <george@tsiokos.com>
7acf13b to
50765d7
Compare
Tests verify three scenarios using secretstores.local.file (no external deps): - optional:true with delayed sidecar: config populates once sidecar starts - optional:false (default): Build() blocks until sidecar ready, secrets populated - Disposal during background load: exits cleanly with no hang Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: George Tsiokos <george@tsiokos.com>
50765d7 to
d33da80
Compare
|
A few items I'm intentionally leaving as-is — noting them here for visibility: Pre-existing
Exponential backoff — The flat Splitting the Non-optional blocking-failure test for config store — Pre-existing gap (the non-optional path throws on WaitForSidecar timeout, but there's no unit test for it). Out of scope for this PR.
|
Summary
Resolves #1748
optionalparameter toAddDaprConfigurationStore,AddStreamingDaprConfigurationStore, andAddDaprSecretStoreextension methods so applications can start without blocking on Dapr sidecar availabilityLoadInBackgroundAsyncin both providers with narrowed exception handling (OperationCanceledException+DaprException) instead of a broadcatch (Exception)that silently swallowed programming errorsCancellationTokenSourcein both providersStringComparerinconsistency (InvariantCultureIgnoreCase→OrdinalIgnoreCase) inFetchSecretsAsyncreadonlyinDaprConfigurationStoreProviderfor consistency withDaprSecretStoreConfigurationProvider.editorconfigand adds missing trailing newlinesTest plan
GetReloadToken()callbacks for deterministic assertions (no fragileTask.Delaypolling)optional: truewith delayed sidecar — config populates once sidecar starts (ShouldPopulateSecretsWhenSidecarStartsLate)optional: false(default) behavior unchanged —Build()blocks until sidecar ready (ShouldBlockAndPopulateSecretsWhenNotOptional)ShouldExitCleanlyWhenDisposedDuringBackgroundLoad)TestContext.Current.CancellationTokenpattern)🤖 Generated with Claude Code